{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%cd /workspace/AI/Datasets/cdla"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import json\n",
    "import os\n",
    "\n",
    "name = \"instances_train\"\n",
    "json_file_name = name + \".json\"\n",
    "\n",
    "with open(json_file_path, \"r\") as f:\n",
    "    data = json.load(f)\n",
    "\n",
    "\n",
    "for image in data[\"images\"]:\n",
    "\n",
    "    file_name_with_path = image[\"file_name\"]\n",
    "    file_name_only = os.path.basename(file_name_with_path)\n",
    "    print(file_name_only)\n",
    "\n",
    "    image[\"file_name\"] = file_name_only\n",
    "\n",
    "with open(\"onlyname_\" + json_file_name, \"w\") as f:\n",
    "    json.dump(data, f, indent=4)"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
